// ExplorerStyle Header

/****************************************************************************
**
** Copyright (c) 2007 Trolltech ASA <info@trolltech.com>
**
** Use, modification and distribution is allowed without limitation,
** warranty, liability or support of any kind.
**
** explorerstyle.h - version 1.0
****************************************************************************/

/*
 * QWindowsNativeStyle.h  0.4.0 / Nov 17, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef QWINDOWSNATIVESTYLE_H
#define QWINDOWSNATIVESTYLE_H

#include <QWindowsVistaStyle>

// QWindowsNativeStyle Class. --------------------------------------------------

/*!
 * \brief Native Windows Style.
 *
 * \note This code is based on the ExplorerStyle 
 *       http://chaos.troll.no/~jbache/explorerstyle.zip) from former Trolltech.
 *       There is no special legal limitation on that code.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class QWindowsNativeStyle : public QWindowsVistaStyle
{
public:
  QWindowsNativeStyle();
public:
  static void initialize(bool appThemed);
public:
  inline static bool isPatchEnabled();
  inline static void setPatchEnabled(bool enabled);
  inline static bool isExplorerStyleEnabled();
  inline static void setExplorerStyleEnabled(bool enabled);
public:
  void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
                     QPainter *painter, const QWidget *widget = 0) const;
  void drawControl(ControlElement element, const QStyleOption *option,
                   QPainter *painter, const QWidget *widget) const;
  void drawComplexControl(ComplexControl control,
                          const QStyleOptionComplex *option, QPainter *painter,
                          const QWidget *widget) const;
  QSize sizeFromContents(ContentsType type, const QStyleOption *option,
                         const QSize &size, const QWidget *widget) const;
  QRect subElementRect(SubElement element, const QStyleOption *option,
                       const QWidget *widget) const;
  QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
                       SubControl sc, const QWidget *widget) const;
  SubControl hitTestComplexControl(ComplexControl control,
                                   const QStyleOptionComplex *option,
                                   const QPoint &position,
                                   const QWidget *widget = 0) const;
  int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
                  const QWidget *widget = 0) const;
  int styleHint(StyleHint hint, const QStyleOption *opt = 0,
                const QWidget *widget = 0,
                QStyleHintReturn *returnData = 0) const;
  virtual QPalette standardPalette() const;
  QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
                         const QWidget *widget = 0) const;
  void polish(QWidget *widget);
  void unpolish(QWidget *widget);
  void polish(QPalette pal);
  void polish(QApplication *app);
  void unpolish(QApplication *app);
private:
  mutable QRect m_currentTopRect;  //current toolbar top area size
  mutable QRect m_currentBottomRect;  //current toolbar bottom area size
private:
  static bool sm_initialized;
  static bool sm_vista;
  static bool sm_appThemed;
  static bool sm_patchDisabled;
  static bool sm_explorerStyle;
private:
  static QFont titleBarFont;
};

// QWindowsNativeStyle :: Public Inline Member Functions. ----------------------

/**
 * \brief Returns \c true if using the patch.
 *
 * \return \c true if using the patch
 */
inline bool QWindowsNativeStyle::isPatchEnabled()
{
  return !sm_patchDisabled;
}

/*!
 * \brief Sets wheter or not applying the patch.
 *
 * \param enabled \c true if applying
 */
inline void QWindowsNativeStyle::setPatchEnabled(bool enabled)
{
  sm_patchDisabled = !enabled;
}

/**
 * \brief Returns \c true if explorer style is enabled.
 *
 * \return \c true if explorer style is enabled
 */
inline bool QWindowsNativeStyle::isExplorerStyleEnabled()
{
  return sm_explorerStyle;
}

/*!
 * \brief Sets wheter or not if explorer style is enabled.
 *
 * \param enabled \c true if enabled
 */
inline void QWindowsNativeStyle::setExplorerStyleEnabled(bool enabled)
{
  sm_explorerStyle = enabled;
}

#endif // QWINDOWSNATIVESTYLE_H
